package com.thl.controller;

import com.thl.annotation.AuthToken;
import com.thl.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
public class UserController {

    @Autowired
    private UserService userService;

    @GetMapping("/test")
    public String test() {
        return "tockenTest";
    }
    @AuthToken
    @RequestMapping(value = "/testTocken", method = RequestMethod.GET)

    public Object testTocken() {
        return "tocken获取成功";
    }

    @PostMapping("/login")
    public Object login(@RequestParam("uname") String uname, @RequestParam("pwd") String pwd) throws Exception {
        Map<String, Object> stringObjectMap = null;
        try {
            stringObjectMap = userService.userLogin(uname, pwd);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return stringObjectMap;
    }
}
